<template>
  <div class="header">
    <!-- 版心 -->
    <div class="wrap headerWrap">
      <!-- logo -->
      <div class="logo">
        <img src="../assets/img/indexLogo.6f8ac4f0.png" alt="" />
      </div>
      <ul class="navs">
        <!-- 高亮:  带有curr类名的,点击的时候,路由一致的时候会高亮 -->
        <li
          :class="{ curr: $route.path == '/home' }"
          @click="$router.push('/home')"
        >
          首页
        </li>
        <li
          :class="{ curr: $route.path == '/goods' }"
          @click="$router.push('/goods')"
        >
          全部商品
        </li>
        <li
          :class="{ curr: $route.path == '/user' }"
          @click="$router.push('/user')"
        >
          个人中心
        </li>
        <li
          :class="{ curr: $route.path == '/order' }"
          @click="$router.push('/order')"
        >
          我的订单
        </li>
        <li
          :class="{ curr: $route.path == '/free' }"
          @click="$router.push('/free')"
        >
          专属福利
        </li>
      </ul>
      <div class="search">
        <input type="text" placeholder="请输入关键字" v-model="searchVal" />
        <span>
          <img src="../assets/img/search.png" alt="" @click="searchFn" />
        </span>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "Jifen4201Header",

  data() {
    return {
      searchVal: "",
    };
  },

  mounted() {},

  methods: {
    searchFn() {
      this.$router.push(`/goods?keyword=${this.searchVal}`);
    },
  },
};
</script>

<style lang="less" scoped>
.header {
  margin: 14px;
  .headerWrap {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .navs {
    display: flex;
    width: 500px;
    justify-content: space-between;
    li {
      cursor: pointer;
    }
    .curr {
      color: #0a328e;
      font-weight: 700;
    }
  }
  .search {
    display: flex;
    input {
      height: 40px;
      border: 1px solid #dedede;
      border-radius: 20px 0px 0px 20px;
      box-sizing: border-box;
      text-indent: 2em;
    }
    span {
      display: block;
      height: 40px;
      line-height: 40px; //行高等于高也可以使居中
      width: 50px;
      background: #0a328e;
      border-radius: 0px 20px 20px 0px;
      text-align: center;
    }
  }
}
</style>